<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
</style>
		<script type="text/javascript">
			$(function() {

				$(".date").datepicker({
					showWeek : true,
					firstDay : 1,
					dateFormat : 'yy-mm-dd',
					showOtherMonths : true,
					selectOtherMonths : true,
				});

				$("#btnClear").click(function() {
					$("#frmSearch input[type=text]").val("");
					$("#frmSearch input[type=checkbox]").prop("checked", false);
				});

				$("#btnCreate").click(function() {
					var name = $("#name").val();
					var number = $("#number").val();

					var url = "firstVisit?name=" + name + "&number=" + number;

					location.href = url;
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<form class="form-horizontal" id="frmSearch">
			<fieldset>
				<legend>来访记录</legend>
				<div class="control-group">
					<label class="control-label">姓名</label>
					<div class="controls">
						<div class="form-inline">
							<label>
								<input id="name" class="input-small" type="text" name="name" value="${param.name}" />
							</label>
							<label>
								电话号码<input id="number" type="text" name="number" value="${param.number}" />
							</label>
							<label class="checkbox">
								只显示本校区人员 <input type="checkbox" <s:if test="#parameters.campus != null">checked="checked"</s:if> name="campus" value="campus" />
							</label>
							<a href="javascript:void(0)" id="btnCreate">新建来访人员</a>
						</div>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">当班前台</label>
					<div class="controls">
						<div class="form-inline">
							<s:iterator value="#users" var="user">
								<label class="checkbox">
									<input type="checkbox" name="creator" value="${user.id}" <s:if test="id in #parameters.creator">checked="checked"</s:if> />${user.name}
								</label>
							</s:iterator>
						</div>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">记录时间范围</label>
					<div class="controls">
						<div class="form-inline">
							<input type="text" class="date input-small" name="startDate" value="${param.startDate}" />~<input type="text" class="date input-small" value="${param.endDate}"
								name="endDate" />
							<button type="submit" class="btn btn-primary">
								<i class="icon-search icon-white"></i> 查询
							</button>
							<button type="button" class="btn" id="btnClear">
								<i class="icon-repeat"></i> 清空
							</button>
						</div>
					</div>
				</div>
			</fieldset>
		</form>
		<table class="table">
			<thead>
				<tr>
					<th style="width: 4em">校区</th>
					<th style="width: 4em">日期</th>
					<th style="width: 4em">时间</th>
					<th style="width: 4em">姓名</th>
					<th style="width: 4em">性别</th>
					<th style="width: 4em">年龄</th>
					<th>联系方式</th>
					<th style="width: 6em">当班前台</th>
					<th style="width: 6em">接待CC</th>
					<th style="width: 6em">来访类型</th>
					<th style="width: 6em">信息来源</th>
					<th style="width: 8em">备注</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="#firstRecordLogs" var="firstRecordLog">
					<tr>
						<td>${firstRecordLog.campus.name }</td>
						<td><s:date name="logTime" format="yyyy-MM-dd" /></td>
						<td><s:date name="logTime" format="HH:ss" /></td>
						<td><s:url id="viewLogByTime" action="viewLogByTime" namespace="/log">
								<s:param name="id" value="student.id"></s:param>
							</s:url> <a href="${viewLogByTime}"> ${firstRecordLog.student.name} </a></td>
						<td><s:property value="student.sex" /></td>
						<td>${firstRecordLog.student.age}</td>
						<td><address class="text-info">
								<abbr> <s:property value="showPhoneNumber(student)" />
								</abbr> <abbr> <s:property value="showMobielNumber(student)" /></abbr>
							</address></td>
						<td>${firstRecordLog.creator.name}</td>
						<td>${firstRecordLog.student.consultor.name}</td>
						<td>...</td>
						<td>${firstRecordLog.source}</td>
						<td><i title="${firstRecordLog.title}" class="icon icon-film"></i></td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
		<jsp:include page="/components/pagination/paginations.jsp"></jsp:include>
	</tiles:putAttribute>
</tiles:insertDefinition>